import GridRender from './render/GridRender'
import BaseRender from './render/BaseRender';
import UIRender  from './render/UIRender'; 
import ImgClipRender from './render/ImgClipRender'
export default class RenderManager{
    renders = new Map();
    customerRenders=[]
   

    constructor(){
        this.renders.set('grid',new GridRender());
        this.renders.set('base',new BaseRender());
        this.renders.set('ui-select',new UIRender());
        this.renders.set('img-clip',new ImgClipRender());
    }
    static instance() {
        if (!RenderManager._instance) {
            RenderManager._instance = new RenderManager();
        }
        return RenderManager._instance;
    }

    getRender(name){
        return this.renders.get(name);
    }
    setRender(name,render,customer=false){
        if(customer){
            this.customerRenders.push(name)
        }
       
        return this.renders.set(name,render);
    }
    render(name){
        let ren = this.getRender(name)
        ren.render()
    }
    renderAll(exclued=[]){
    
        let list = [...this.renders.values()]
       
        list.sort((a,b)=>a.order-b.order).forEach((render,key)=>{
          
            if(!exclued.includes(key)){
                // console.log(render)
                if(!render.unAutoRender){
                    render.render()
                }
           
            }

           
        })
    }
  
}